import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export default new Router({
  mode: "history",
  base: process.env.BASE_URL,
  routes: [
    { path: "/index.html", redirect: { name: "login" } },
    {
      path: '/',
      name: 'mainView',
      component: () => import('../views/main/index.vue'),
      redirect: '/login',
      children: [

        // 登录
        {
          path: 'login',
          name: 'login',
          component: () => import('../views/main/login/login.vue')
        },
        // 统计模块
        {
          path: 'static',
          redirect: 'static/statistics',
          component: () => import('../views/main/asset/index.vue'),
          children:[
            //资产统计
            {
              path: 'statistics',
              name: 'statistics',
              component: () => import('../views/main/asset/views/statistics.vue')
            },
            //资产二级分类统计
            {
              path: 'statisticsSecondClass',
              name: 'statisticsSecondClass',
              component: () => import('../views/main/asset/views/statistics-second-class.vue')
            },
            //资产统计详情
            {
              path: 'statisticsDetail',
              name: 'statisticsDetail',
              component: () => import('../views/main/asset/views/statistics-detail.vue')
            },
            {
              path: 'log',
              name: 'log',
              component: () => import('../views/main/asset/views/log.vue')
            },
            {
              path: 'search',
              name: 'search',
              component: () => import('../views/main/asset/views/search.vue')
            },
             //全院选择资产盘点
             {
              path: 'allInventory',
              name: 'allInventory',
              component: () => import('../views/main/asset/views/allInventory.vue')
            },
            //全院选择盘点人盘点
            {
              path: 'allReopleInventory',
              name: 'allReopleInventory',
              component: () => import('../views/main/asset/views/allReopleInventory.vue')
            },
            //资产盘点
            {
              path: 'inventory',
              name: 'inventory',
              component: () => import('../views/main/asset/views/inventory.vue')
            },
            //资产盘点
            {
              path: 'inventoryDetail',
              name: 'inventoryDetail',
              component: () => import('../views/main/asset/views/inventoryDetail.vue')
            },
          ]
        },
        // 资产管理模块
        {
          path: 'asset',
          redirect: 'asset/assetHome',
          component: () => import('../views/main/asset/index.vue'),
          children:[
            {
              path: 'assetHome',
              name: 'assetHome',
              component: () => import('../views/main/asset/home.vue')
            },
            {
              path: 'log',
              name: 'log',
              component: () => import('../views/main/asset/views/log.vue')
            },
            {
              path: 'registration',
              name: 'registration',
              component: () => import('../views/main/asset/views/registration.vue')
            },
            // 资产操作中心 归还、借出、转移
            {
              path: 'assetOpt',
              name: 'assetOpt',
              component: () => import('../views/main/asset/views/assetOpt.vue')
            },
            //资产归还提交
            {
              path: 'assetReturn',
              name: 'assetReturn',
              component: () => import('../views/main/asset/views/assetReturn.vue')
            },
            //资产借用提交
            {
              path: 'assetLend',
              name: 'assetLend',
              component: () => import('../views/main/asset/views/assetLend.vue')
            },
            //资产转移提交
            {
              path: 'assetTransfer',
              name: 'assetTransfer',
              component: () => import('../views/main/asset/views/assetTransfer.vue')
            },
            //资产转移单
            {
              path: 'ZhuanYiDan',
              name: 'ZhuanYiDan',
              component: () => import('../views/main/asset/views/ZhuanYiDan.vue')
            },
            //资产转移详情
            {
              path: 'transferDetail',
              name: 'transferDetail',
              component: () => import('../views/main/asset/views/transferDetail.vue')
            },
            //资产盘点
            {
              path: 'inventory',
              name: 'inventory',
              component: () => import('../views/main/asset/views/inventory.vue')
            },
            //借据单
            {
              path: 'promissoryNote',
              name: 'promissoryNote',
              component: () => import('../views/main/asset/views/promissoryNote.vue')
            },
            //借据单详情
            {
              path: 'promissoryDetail',
              name: 'promissoryDetail',
              component: () => import('../views/main/asset/views/promissoryDetail.vue')
            },
            //创建盘点
            {
              path: 'assetInventory',
              name: 'assetInventory',
              component: () => import('../views/main/asset/views/assetInventory.vue')
            },
            //全院选择资产盘点
            {
              path: 'allInventory',
              name: 'allInventory',
              component: () => import('../views/main/asset/views/allInventory.vue')
            },
            //全院选择盘点人盘点
            {
              path: 'allReopleInventory',
              name: 'allReopleInventory',
              component: () => import('../views/main/asset/views/allReopleInventory.vue')
            },
            //资产盘点
            {
              path: 'inventoryDetail',
              name: 'inventoryDetail',
              component: () => import('../views/main/asset/views/inventoryDetail.vue')
            },
            //资产接收
            {
              path: 'receive',
              name: 'receive',
              component: () => import('../views/main/asset/views/receive.vue')
            },
            //资产详情
            {
              path: 'receiveDetail',
              name: 'receiveDetail',
              component: () => import('../views/main/asset/views/receiveDetail.vue')
            },
            //资产归还
            {
              path: 'receiveReturn',
              name: 'receiveReturn',
              component: () => import('../views/main/asset/views/receiveReturn.vue')
            },
            //资产搜索
            {
              path: 'search',
              name: 'search',
              component: () => import('../views/main/asset/views/search.vue')
            },
            // //资产借用接收
            // {
            //   path: 'receiveLend',
            //   name: 'receiveLend',
            //   component: () => import('../views/main/asset/views/receiveLend.vue')
            // },
          ]
        },
        // 管理模块
        {
          path: 'manage',
          redirect: 'manage/class',
          component: () => import('../views/main/asset/views/manage/index.vue'),
          children:[
            // 类别
            {            
              path: 'class',
              name: 'class',
              component: () => import('../views/main/asset/views/manage/assetClass.vue')
            },
            {            
              path: 'classChildren',
              name: 'classChildren',
              component: () => import('../views/main/asset/views/manage/classChildren.vue')
            },
            // 品牌
            {
              path: 'brandChildre',
              name: 'brandChildre',
              component: () => import('../views/main/asset/views/manage/brandChildre.vue')
            },
            // 品牌
            {
              path: 'placeManage',
              name: 'placeManage',
              component: () => import('../views/main/asset/views/manage/placeManage.vue')
            },
          ]
        },
      ]
    }
  ],
  scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      // 如果之前有保存的滚动位置，直接恢复
      return savedPosition
    } else {
      // 否则滚动到页面顶部
      return { x: 0, y: 0 }
    }
  }
})
